package com.nursing.controller.admin;

import com.github.pagehelper.PageInfo;
import com.nursing.bean.CarePlan;
import com.nursing.bean.CareTask;
import com.nursing.model.Result;
import com.nursing.model.dto.CareTaskDto;
import com.nursing.service.CarePlanService;
import com.nursing.service.TaskService;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/task")
public class AdminCareTaskController {
    private final TaskService service;

    public AdminCareTaskController(TaskService service) {
        this.service = service;
    }

    @GetMapping("/getTaskList")
    public Result<PageInfo<CareTaskDto>> getPlanList(@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10")int size) {
        return Result.success(service.list(page, size));
    }

    @DeleteMapping("/deleteTask")
    public Result<CareTask> deleteTask(@RequestParam Integer id) {
        service.deleteTask(id);
        return Result.success("删除成功");
    }

    @PostMapping("/addTask")
    public Result<String> addTask(@RequestBody CareTask careTask) {
        service.addTask(careTask);
        return Result.success("添加成功");
    }



}
